home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / lib231.arc / CAPCMD.SLT < prev    next >
Text File  |  1990-05-11  |  4KB  |  88 lines

  1. ////////////////////////////// CAPCMD.SLT ////////////////////////////////////
  2. //
  3. // CAPCMD.SLT Copyright (C) 1990 Liberation Enterprises.
  4. //
  5. // DESCRIPTION:  This script is designed to be used in one of Custom Command
  6. // options of any Liberator Command File.  The script captures the results
  7. // of a user-defined PCBoard/ProDoor command to a user-defined file.
  8. //
  9. // INSTRUCTIONS:  Simply place the name of the capture file, along with the
  10. // command to send to PCBoard/ProDoor in Custom Command 1 or 2 in the follow-
  11. // ing format:
  12. //
  13. // @CapCmd <capfname> <command>
  14. //
  15. // To capture bulletin 6 to the file C:\TEMP\B6.CAP, the appropriate Custom
  16. // Command would be:
  17. //
  18. // @CapCmd C:\TEMP\B6.CAP B 6 NS
  19. //
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Below are two things called 'variables', that I'm sure you've seen in other
  22. // scripts.  Once defined, they simply provide a place to store some numbers
  23. // (int) or letters (str) in memory, to be retrieved later.  If you have to
  24. // keep track of something in your scripts, just define variables as below.
  25. // int for numbers, str for 'strings' or groups of letters, symbols, etc.
  26. // the [64] means that the string can hold up to 64 characters.
  27.  
  28. int old_capture_stat;      // holds status of current capture file (open/closed)
  29. str old_capture_fname[64]; // holds name of current capture file
  30.  
  31. //////////////////////////////////////////////////////////////////////////////
  32. main(str fname, str cmd)
  33. {
  34.  if (not fname)              // check passed parameters, abort if none
  35.   return;                    // 'not fname' is TRUE if the str is empty
  36.  if (not cmd)
  37.   return;
  38.  
  39.  cputs(cmd);                 // send the passed cmd to the BBS
  40.  cputs("^M");                // along with a CR or <Enter>
  41.  
  42.  if (open_capture(fname))    // if open_capture() returns TRUE...
  43.   waitfor("Command? ", 300); // wait up to 5 minutes for a main prompt
  44.  
  45.  restore_capture();          // restore_capture() is defined below
  46. }
  47.  
  48. //////////////////////////////////////////////////////////////////////////////
  49. open_capture(str capfname)
  50. {
  51.  old_capture_stat = capture_stat();  // capture_stat() as explained in SALT dox
  52.  old_capture_fname = _capture_fname; // _capture_fname 'system variable' holds
  53.                                      // the name of the current capture file
  54.                                      // this stores the current name...
  55.  
  56.  _capture_fname = capfname;          // then replace with user-defined name
  57.  
  58.  if (capture_stat())                 // if capture file now open...
  59.   capture("*CLOSE*");                // close it...
  60.  
  61.  if (capture(_capture_fname) == -1)  // and try to open the new one
  62.   {
  63.    status_wind("Error opening capture file!", 30);
  64.    return(0);                        // return FALSE (zero) if error
  65.   }
  66.  
  67.  // the above if() may look a little strange, but what is means is:
  68.  // 'if() the return value of capture() is equal to (==) -1'.  The capture()
  69.  // function returns -1 when it can't open the specified _capture_fname, thus
  70.  // what's between the curly brackets gets executed 'if capture() returns -1'.
  71.  
  72.  return(1);                          // return TRUE (non-zero) if okay
  73. }
  74.  
  75. //////////////////////////////////////////////////////////////////////////////
  76. restore_capture()
  77. {
  78.  if (capture_stat())
  79.   capture("*CLOSE*");                // all done... close capture file
  80.  
  81.  _capture_fname = old_capture_fname; // put the old capture file name back
  82.                                      // (stored in open_capture() at start)
  83.  
  84.  if (old_capture_stat)               // if the capture file was open when we
  85.   capture(_capture_fname);           // started, then re-open it.
  86. }
  87.  
  88. //////////////////////////////////////////////////////////////////////////////